<%@ page import="com.xiaolin.utils.dbUtils" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="com.xiaolin.dao.impl.UserDAOImpl" %>
<%@ page import="com.xiaolin.bean.User" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/1/5
  Time: 15:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查看个人信息</title>
    <link rel="stylesheet" href="../css/viewPerIn.css" type="text/css">
</head>
<body>
<div>
    <%
        int id = Integer.parseInt(request.getParameter("id"));
//        out.print(id);
        if (id == 1) {
    %>
    <h1>查看个人信息</h1>
    <%
        Connection conn = dbUtils.getConnection();
        UserDAOImpl uD = new UserDAOImpl();
        User ac = uD.getUserByAcNum(conn, request.getParameter("acNum"));
    %>
    <table>
        <tr>
            <td>姓名：</td>
            <td><%=ac.getName()%>
            </td>
        </tr>
        <tr>
            <td>账号：</td>
            <td><%=ac.getAcNum()%>
            </td>
        </tr>
        <tr>
            <td>年龄：</td>
            <td><%=ac.getAge()%>
            </td>
        </tr>
        <tr>
            <td>邮箱</td>
            <td><%=ac.getEmail()%>
            </td>
        </tr>
        <tr>
            <td>电话：</td>
            <td><%=ac.getPhone()%>
            </td>
        </tr>
    </table>
    <%
    } else if (id == 2) {
        Connection conn = dbUtils.getConnection();
        UserDAOImpl uD = new UserDAOImpl();
        User ac = uD.getUserByAcNum(conn, request.getParameter("acNum"));
    %>
    <h1>修改个人信息</h1>
    <form method="post" action="evePerIn.jsp?id=1">
        <table>
            <tr>
                <td>姓名：</td>
                <td><input type="text" value="<%=ac.getName()%>" name="name"></td>
            </tr>
            <tr>
                <td>账号：</td>
                <%--                readonly修改不了，但是request.getParameter("acNum");可以获取
                                    disabled="disabled"文本框修改不了，request.getParameter("acNum") 获取到的为空！--%>
                <td><input type="text" value="<%=ac.getAcNum()%>" name="acNum" readonly="readonly"></td>
            </tr>
            <tr>
                <td>年龄：</td>
                <td><input type="text" value="<%=ac.getAge()%>" name="age"></td>
            </tr>
            <tr>
                <td>邮箱：</td>
                <td><input type="text" value="<%=ac.getEmail()%>" name="email"></td>
            </tr>
            <tr>
                <td>电话：</td>
                <td><input type="text" value="<%=ac.getPhone()%>" name="phone"></td>
            </tr>
            <tr>
                <td><input type="submit" value="提交"></td>
                <td><input type="reset" value="重置"></td>
            </tr>
        </table>
    </form>
    <%
    } else if (id == 3) {
        String acNum = request.getParameter("acNum");
        Connection conn = dbUtils.getConnection();
        UserDAOImpl uD = new UserDAOImpl();
        User ac = uD.getUserByAcNum(conn, request.getParameter("acNum"));
    %>
    <script type="text/javascript" src="script/jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#pw1").blur(function () {
                var pw1 = $("#pw1").val()
                var pw = $("#pw").val();
                if (pw1 != pw) {
                    $("#sp").text("密码输入错误！")
                } else {
                    $("#sp").text("密码输入正确！")
                }
            })
            $("#pw3").blur(function () {
                var pw1 = $("#pw2").val()
                var pw = $("#pw3").val();
                if (pw1 != pw) {
                    $("#sp2").text("输入不一致！")
                } else {
                    $("#sp2").text("输入一致！")
                }
            })
        })
    </script>
    <h1>修改密码</h1>
    <form method="post" action="evePerIn.jsp?id=2">
        <input type="hidden" value="<%=ac.getEmail()%>" name="email">
        <input type="hidden" value="<%=ac.getPassWord()%>" name="pw" id="pw">
        <table>
            <tr>
                <td>原密码：</td>
                <td><input type="password" name="pw1" id="pw1"></td>
                <td><span id="sp" style="font-size: 20px"></span></td>
            </tr>
            <tr>
                <td>修改为：</td>
                <td><input type="password" name="pw2" id="pw2"></td>
            </tr>
            <tr>
                <td>再次输入：</td>
                <td><input type="password" name="pw3" id="pw3"></td>
                <td><span id="sp2" style="font-size: 20px"></span></td>
            </tr>
            <tr>
                <td><input type="submit" value="提交"></td>
                <td><input type="reset" value="重置"></td>
            </tr>
        </table>
    </form>
    <%
    } else if (id == 4) {
    %>
    <h1>注销账号</h1>
    <form method="post" action="evePerIn.jsp?id=3&acNum=<%=request.getParameter("acNum")%>">
        <table>
            <tr>
                <td>确定注销此账号？</td>
            </tr>
            <tr>
                <td><input type="submit" value="确定"></td>
                <td></td>
            </tr>
        </table>
    </form>
    <%
        }
    %>
</div>
</body>
</html>
